<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style type="text/css">
	form{
		padding-top: 50px;
		text-align: center;
	}
	#main_input{
		width: 400px;
		height: 30px;
		margin-bottom: 30px;
	}
	#main_sub{
		margin: 20px;
		width: 200px;
		height: 40px;
	}
	</style>
</head>
<body>
<?php
include_once("header.php");
?>

<?php
include_once("database.php");
if(isset($_GET["action"])&&$_GET["action"]=="show"&&isset($_GET["subjectid"])){
		$subjectid=$_GET["subjectid"];
	}else{
		$subjectid=0;//指定一个友好的错误新消息界面
	}
	//首先查询指定的主题信息
	$selectsubject="select * from link where subjectid='$subjectid'";
	include_once("database.php");
	$result=mysql_query($selectsubject) or die("查询{$subjectid}主体信息失败:".mysql_error()."<br/>");
	if(mysql_num_rows($result)>0){
		$row=mysql_fetch_array($result);
		$name=$row["name"];
		$website=$row["website"];
		echo <<<xqquestion
		<form action="" method="post">
		网页：<input type="text" name="name" id="main_input" value="$name"><br/><br/>
		网址：<input type="text" name="website" id="main_input" value="$website"><br/><br/>
		<br/><br/>
		<input type="submit" name="submit" value="修改"id="main_sub"><input type="submit" name="submit" value="删除" id="main_sub">
		</form>
xqquestion;
}
if(isset($_POST["submit"])&&$_POST["submit"]=="修改"){
	if(isset($_COOKIE["type"])&&$_COOKIE["type"]=="管理员") {
		$name=$_POST["name"];
		$website=$_POST["website"];
		$updategonggao="update link set name='$name',website='$website'";
		@mysql_query($updategonggao) or die("修改信息失败:".mysql_error()."<br/>");
	echo "<script>alert('修改信息成功');</script>";
	echo "<script>window.opener.location.reload('index.php');window.close(); </script>";
	}else{
		echo "<script>alert('你还不是管理员，没有修改权限');</script>";
	}
}
if(isset($_POST["submit"])&&$_POST["submit"]=="删除"){
	if(isset($_COOKIE["type"])&&$_COOKIE["type"]=="管理员") {
		$name=$_POST["name"];
		$deletebooksql="delete from link where name='{$name}'";
		@mysql_query($deletebooksql) or die("删除标题为:".$name." 的信息失败:".mysql_error()."<br/>");
	echo "<script>alert('删除信息成功');</script>";
	echo "<script>window.opener.location.reload('index.php');window.close(); </script>";
	}else{
		echo "<script>alert('你还不是管理员，没有删除权限');</script>";
	}
}
?>
<?php
include_once("footer.php");
?>
</body>
</html>